﻿<!--#include virtual="/Common/Config.asp" -->
<!--#include virtual="/Common/Conn.asp" -->
<!--#include virtual="/Common/Cls_Upload.asp" -->
<!--#include virtual="/Common/Function.asp" -->
<%
If Session("Admin_UserName")="" Or IsNull(Session("Admin_UserName")) Then 
	endd
End If 
Server.ScriptTimeOut = 1800

Dim sAction
sAction = UCase(Trim(Request.QueryString("action")))

Select Case sAction
Case "SAVE"
	'Call ShowForm()			' 显示上传表单
	Call DoSave()			' 存文件
Case Else
	Call ShowForm()			' 显示上传表单
End Select



Sub ShowForm() 
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>文件上传</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
*{ margin:0; padding:0;}
body{ background:#f7faff;}
.inupload,.inupload input{ vertical-align:middle;}
.itxt,.button{ border:1px solid #ccc; height:20px;line-height:20px;}
.itxt{ width:180px;}
</style>
</head>
<body>
<div class="inupload">
<form action="?action=save&change_field=<%=requery("change_field")%>" method="post" name="myform" enctype="multipart/form-data">
<input type="file" name="uploadfile" size="1" class="itxt">
<input type="submit" name="submit" value="上传" class="button">
</form>
</div>

<script language=javascript>

var sAllowExt = "jpg|gif|png";
// 检测上传表单
function CheckUploadForm() {
	if (!IsExt(document.myform.uploadfile.value,sAllowExt)){
		parent.UploadError("提示：\n\n请选择一个有效的文件，\n支持的格式有（"+sAllowExt+"）！");
		return false;
	}
	return true
}

</script>

</body>
</html>
<% 
End Sub 

' 保存操作
Sub DoSave()
	' 默认无组件上传类
	Call DoUpload_Class
	
End Sub


Sub DoUpload_Class()

	'On Error Resume Next


	change_field = requery("change_field")

	Dim  Aspto,ImageName,FormName
	Set  Aspto = new Cls_Upload

	
	Aspto.FileType = Upload_FileType
	Aspto.MaxSize  = Max_Upload_Size
	Aspto.SavePath = Upload_SavePath
	Aspto.Open() 
	If Aspto.Error<>0 Then  '发生错误
		Set Aspto = Nothing 
		AlertBox "发生错误，请检查你上传的文件!","javascript:history.go(-1)"	
	End If 

	If Aspto.Form("uploadfile")="" Then 
		Set Aspto = Nothing 
		AlertBox "请选择要上传的文件!","javascript:history.go(-1)"	
	End If 

	sSaveFileName = Aspto.Form("uploadfile")
	Set Aspto = nothing 
	Response.Write "<Script language='JavaScript'>"
	Response.Write "parent.document.getElementById("""&change_field&""").value="""&sSaveFileName&""";"
	Response.Write "window.location.href='File_Upload.asp?change_field="&change_field&"';"
	Response.Write "</Script>"
	response.End 

End Sub


' 输出客户端脚本
Sub OutScript(str)
	Response.Write "<script language=javascript>" & str & ";history.back()</script>"
End Sub
Sub OutScriptNoBack(str)
	Response.Write "<script language=javascript>" & str & "</script>"
End Sub



%>